package cn.gson.crm.controller;

import cn.gson.crm.model.pojos.*;
import cn.gson.crm.model.service.Ggservice;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/gg")
public class GgController {
    @Autowired
    Ggservice ggservice;
    @RequestMapping("/ggz")
    @ResponseBody
    public Map<String,Object> gg(String lb){
        System.out.println("lb:"+lb);
        List<Specifications> list = ggservice.ggselect(lb);
        Map<String,Object> map = new HashMap<>();
        map.put("row",list);
        return map;
    }
    //查询类别
    @RequestMapping("/bie")
    @ResponseBody
    public List<Category> bie(){
        return ggservice.bie();
    }

    //查询规格名
    @RequestMapping("/gm")
    @ResponseBody
    public List<Specifications> ming(){
        return ggservice.ming();
    }

    //根据规格名和类别查询规格值
    @RequestMapping("ggmc")
    @ResponseBody
    public Map<String,Object> ggmc(String ggmc,String gglb){
        System.out.println("ggmc:"+ggmc);
        List<SpecifValue> list = ggservice.ggmc(ggmc,gglb);
        Map<String,Object> map = new HashMap<>();
        map.put("row",list);
        return map;
    }


    @RequestMapping("ggmcc")
    @ResponseBody
    public Map<String,Object> ggmc(){
        List<SpecifValue> list = ggservice.ggmcc();
        Map<String,Object> map = new HashMap<>();
        map.put("row",list);
        return map;
    }

    //新增规格
    @RequestMapping("/xinzen")
    @ResponseBody
    public void xz(@RequestBody Ggxz ggxz){
        System.out.println("规格:"+ggxz);
        ggservice.ggxz(ggxz);
    }

    //树形控件
    @RequestMapping("/cxlb")
    @ResponseBody
    public List<Cate> cxlb(){
        return ggservice.cxlb();
    }

    //删除
    @RequestMapping("/sc")
    @ResponseBody
    public void sc(Integer ggzId){
        System.out.println("111"+ggzId);
        ggservice.shan(ggzId);
    }

    @RequestMapping("/zhi")
    @ResponseBody
    public List<SpecifValue> zhi(Integer geid,Integer bieid){
        return ggservice.zhi(geid,bieid);
    }

    @RequestMapping("/cs")
    @ResponseBody
    public List<SpecifValue> cs(String mingzi,Integer leiming){
        return ggservice.cs(mingzi,leiming);
    }
}
